/*--------------------------------------------------------------------------------*/
#ifndef __GRAPHIC_ANIMATION_DATA__
#define __GRAPHIC_ANIMATION_DATA__
/*--------------------------------------------------------------------------------*/
#include "primitives.h"
#include "object.h"
#include "util.h"
#include "graphic_texture_set.h"
#include "defs.h"
/*--------------------------------------------------------------------------------*/
class GRAPHIC_ANIMATION_DATA : public OBJECT
{

	// -- PUBLIC

public:

    DECLARE_REF( GRAPHIC_ANIMATION_DATA );

    // .. CONSTRUCTORS

    GRAPHIC_ANIMATION_DATA() : OBJECT(), TextureSetSource(), FrameTable(), Duration( 0.0f )
    {

    }

    virtual ~GRAPHIC_ANIMATION_DATA()
    {
    }

    // .. METHODS

    VOID SetTextureSetSource( const GRAPHIC_TEXTURE_SET::REF & source )
    {
    	TextureSetSource = source;
    }

    const GRAPHIC_TEXTURE_SET & GetTextureSetSource() const
    {
    	return *TextureSetSource;
    }

    VOID SetDuration( const REAL duration )
    {
    	Duration = duration;
    }

    const REAL & GetDuration() const
    {
    	return Duration;
    }

    const GRAPHIC_TEXTURE_SET::UV_COORD & GetUVCoord( const REAL current_time ) const
    {
    	DEBUG_Require( current_time < Duration );

    	return TextureSetSource->GetUVCoord( FrameTable[ ( INDEX )( ( current_time / Duration ) * FrameTable.GetItemCount() ) ] );
    }

    VOID AddFrame( const INDEX index )
    {
    	FrameTable.Add( index );
    }

    VOID AddFramesInRange( const INDEX from_index, const INDEX to_index )
    {
    	INDEX
			index;

    	for_each_index_in_range( index, from_index, to_index )
    	{
        	FrameTable.Add( index );
    	}
    }

    // -- PRIVATE

private :

    // .. ATTRIBUTES

    GRAPHIC_TEXTURE_SET::REF
		TextureSetSource;
    ARRAY< INDEX >
		FrameTable;
    REAL
		Duration;
    
};
/*--------------------------------------------------------------------------------*/
#endif
